﻿using Common.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Database.Mappers
{
    public partial class Mapper
    {
        public PlaceDTO Map(Place place)
        {
            return new PlaceDTO
            {
                Id = place.Id,
                Character = Map(place.Character),
                Tile = Map(place.Tile)
            };
        }

        

        public Place Map(PlaceDTO place)
        {
            return new Place
            {
                Id = place.Id,
                Character = Map(place.Character),
                Tile = Map(place.Tile)
            };
        }

        public List<PlaceDTO> Map(ICollection<Place> places)
        {
            return places.Select(place => new PlaceDTO()
            {
                Id = place.Id,
                Character = Map(place.Character),
                Tile = Map(place.Tile)
            }).ToList();
        }

        public ICollection<Place> Map(ICollection<PlaceDTO> places)
        {
            if (places == null)
                return null;

            return places.Select(place => new Place()
            {
                Id = place.Id,
                Character = Map(place.Character),
                Tile = Map(place.Tile)
            }).ToList();
        }
    }
}
